import Dao.StudentDao;
import Dao.UserDao;
import Impl.StudentDaoImpl;
import com.google.gson.Gson;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import model.Result;
import model.Student;
import model.User;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapHandler;
import util.C3P0Util;
import util.Md5Util;

import javax.sql.DataSource;
import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;

public class Test {
    public static void main(String[] args) throws IOException, SQLException {
//        //1.创建数据库连接池对象
//        DataSource ds = new ComboPooledDataSource();
//        //2.获取连接对象
//        Connection conn = ds.getConnection();
//        //3.打印
//        System.out.println(conn);

//        UserDao userDao=new UserDao();
//        StudentDaoImpl studentDao=new StudentDao();
//        int result=0;
//        if(userDao.deleteUser("0001")>0)
//            result=studentDao.deleteStudent("1");
//        if(result>0)
//            System.out.println("OK");

//        UserDao userDao=new UserDao();
//      //  List<User> user= userDao.getIdByStuNo("180804110");
//        System.out.println(userDao.getIdByStuNo("1"));
//        Gson gson=new Gson();
//        String json=gson.toJson(user);
//        System.out.println(json);
//        for(User u:user)
//            System.out.println(u.getUserName());

//        String stuNo="180804110";
//        String stuName="黄浩东";
//        String classes="1808042";
//        String gender="女";
//        String department="软件工程";
//        String tel="15676190930";
//        String dormno="10405";
//        Student student=new Student(stuNo,stuName,classes,gender,department,tel,dormno,"");
//        StudentDaoImpl studentDao = new StudentDao();
//        System.out.println(studentDao.updateStudent(student));



//        StudentDaoImpl studentDao = new StudentDao();
//        List<Student> student=studentDao.getStudentByStuNo("180804110");
//        System.out.println(student);
//        List<Student> allstudent = null;
//        try {
//            allstudent = studentDao.getAllStudent();
//        } catch (SQLException throwables) {
//            throwables.printStackTrace();
//        }
//
//        System.out.println(allstudent);

        Student student=new Student("1","2");
        StudentDaoImpl studentDao=new StudentDao();
        studentDao.saveStudent(student);

//        User u=new User("789","789");
//        UserDao userDao = new UserDao();
//        userDao.saveUser(u);
//        boolean result=userDao.checkLogin(u);
//        if(result)
//            System.out.println("Y");
//        else
//            System.out.println("N");
    }
}